package com.szholly.pro.watergas_server.ps.service;

import java.util.List;
import java.util.Map;

import com.szholly.data.general.ITable;
import com.szholly.data.general.ITableFactory;
import com.szholly.data.general.RowBase;
import com.szholly.pro.watergas_server.common.data.DataUtil;
import com.szholly.utils.spring.SpringBeanFactory;
import org.springframework.stereotype.Service;


/**
 * 人工监测服务
 * 
 * @author Administrator
 *
 */
@Service
public class ArtificialMonitorService {
	/**
	 * 获取人工监测任务数据记录列表
	 * 
	 * @param resqMap
	 * @return
	 */
	public List<RowBase> getArtificialMonitorDataList(Map<String, String> resqMap) {
		if (resqMap == null)
			return null;

		String strSTATION_ID = resqMap.get("STATION_ID");
		String strPARAM_ID = resqMap.get("PARAM_ID");
		String strJOB_ID = resqMap.get("JOB_ID");
		String strSTART_TIME = resqMap.get("START_TIME");
		String strEND_TIME = resqMap.get("END_TIME");
		if (strSTATION_ID == null || strSTATION_ID.length() < 1 || strPARAM_ID.length() < 1 || strJOB_ID.length() < 1)
			return null;

		String strSQL = " select t.TASK_CODE, t.TASK_STATUS, t.START_TIME as TASK_START_TIME, t.END_TIME as TASK_END_TIME, t.FINISH_TIME as TASK_FINISH_TIME,  \n"
				+ " t1.*, \n" + " t2.NAME as STATION_NAME, \n" + " t3.GROUP_NAME as GROUP_NAME, \n"
				+ " t4.C_USEREALNAME as USER_NAME \n" + " from OP_TASK t \n"
				+ " inner join OPERATION_ARTIFICIAL_MONITOR t1 ON t1.TASK_CODE = t.TASK_CODE \n" // dif
				+ " left join BC_SITE_INFO t2 on t2.EXP_NO = t.STATION_ID \n"
				+ " left join OC_GROUP t3 on t3.GUID = t.OPERATION_GROUP_ID \n"
				+ " left join SAFE_USER t4 on t4.S_USERID = t.FINISH_BY \n" + " where t.STATION_ID = '" + strSTATION_ID
				+ "' \n" + " AND t.JOB_ID = '" + strJOB_ID + "' \n" + " AND t1.MONITOR_PARM = '" + strPARAM_ID + "' \n" // dif
				+ " AND t.START_TIME >= to_date('" + strSTART_TIME + " 00:00:00', 'yyyy-mm-dd hh24:mi:ss') \n"
				+ " AND t.START_TIME <= to_date('" + strEND_TIME + " 00:00:00', 'yyyy-mm-dd hh24:mi:ss') \n"
				+ " order by t.START_TIME desc ";

		ITableFactory tableFactory = (ITableFactory) SpringBeanFactory.getBean("TableFactory");
		ITable pTable = tableFactory.openTable("TASKQUERYDIC");
		List<RowBase> rcdList = DataUtil.getSelectRows(strSQL, null, pTable);
		return rcdList;
	}
}
